<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table.js"></script>
    <script src="__STATIC__/bootstrap-table/js/bootstrap-table-zh-CN.min.js"></script>
    <script src="__STATIC__/bootstrap-table/js/dropdown.js"></script>
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap-table.min.css">
    <link rel="stylesheet" href="__STATIC__/bootstrap-table/css/bootstrap.css">
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <script src="__STATIC__/js/common.js"></script>
</head>
<body>
<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
<form class="layui-form" id="adminList" action="" style="width: 30%;" onsubmit="return false">
    <br>
    <input type="text" value="{$data.help_id}" hidden id="id">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" value="{$data.help_tittle}" id="title"   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">发布人</label>
        <div class="layui-input-block">
            <input type="text" value="{$data.get_teacher.teacher_name}"  readonly="readonly" id="teacher"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">发布人学校</label>
        <div class="layui-input-block">
            <input type="text" value="{$data.get_teacher.school.school_name}"  readonly="readonly" id="school"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">内容</label>
        <div class="layui-input-block">
            <textarea id="question" style="width: 100%;height: 300px" >{$data.help_question}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">回答</label>
        <div class="layui-input-block">
            <textarea id="answer" style="display: none;">{$data.help_answer}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">发布时间</label>
        <div class="layui-input-block">
            <input type="text" value="{$data.create_time}" name="title"  readonly="readonly" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo" id="add">立即修改</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
</html>
<script>
    layui.use('layedit', function(){
        layedit = layui.layedit;
        index  = layedit.build('answer',{
            tool: ['left', 'center', 'right','strong' //加粗
                ,'italic' //斜体
            ]
        }); //建立编辑器
        layedit.getContent(index);
    });
</script>
<script>
    $("#add").click(function (){
        var id = $("#id").val();
        var question = $("#question").val();
        var answer =  layedit.getContent(index);
        var title    = $("#title").val();

        $.ajax({
            url:"{:url('/question/updateQuestion')}",
            data:{id:id,answer:answer,question:question,title:title},
            type:"post",
            dataType:"json",
            success:function(res){
                if(res.code){
                    layer.msg(res.msg,{icon:1,time:2000},function(){
                        $("#adminList").bootstrapTable(('refresh'));
                    });
                    return;
                }else{
                    layer.msg(res.msg,{icon:5,time:2000});
                    return;
                }
            }
        })
    })
</script>
